package com.uu.config;

import com.uu.global.StandardResult;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionAdvice {

    /**
     * 处理 java.lang.Exception
     * @param exception
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public StandardResult handleException(Exception exception) {
        return StandardResult.builder().errorMsg(exception.getLocalizedMessage()).build();
    }
}
